/*
 * @Author       : wangzeyu 2309335887@qq.com
 * @Date         : 2023-06-25 14:45:12
 * @LastEditors  : WangZeYu
 * @LastEditTime : 2023-06-25 15:09:09
 * @FilePath     : \algorithm\selectionSort.js
 * @Description  : 选择排序
 */
function selectionSort(arr){
  let index
  for(let i = 0; i < arr.length-1; i++){
    index = i
    for(let j = i+1; j < arr.length; j++){
      if(arr[j] < arr[index]){
        index = j
      }
    }
    let temp = arr[i]
    arr[i] = arr[index]
    arr[index] = temp

  }
  return arr
}
let a = [56,3,5,11]
console.log(selectionSort(a))